#!/bin/sh

set -e
DJPATH=http://localhost/domjudge/team/identify.php
DJDIR=$HOME/.domjudge

# Create if not exists yet
mkdir -p $DJDIR
# Unconditionally enforce correct permissions
chown $USER $DJDIR
chmod 0700 $DJDIR

# Clean up any leftovers
rm -f $DJDIR/identify.*

# Create 
TMPFILE=`basename mktemp $DJDIR/identify.XXXXXXXXXX`

if ! wget -q -O - "$DJPATH?login=$USER&key=$TMPFILE"; then
	echo "Failed to connect."
fi

